package org.sam.beatles.integrations;

import java.util.Collection;

import org.sam.swing.table.JSTableColumn;
import org.sam.swing.table.JSTableModel;
import org.sam.swing.table.JSTableModelLinster;
import org.sam.swing.table.defaultImpl.JSTableDefaultBuilderImpl;

/**
 * jap数据表格操作对象
 * 
 * @author sam
 *
 * @param <E>
 */
public class JSTableHttpClientBuilderImpl<E> extends JSTableDefaultBuilderImpl<E> {

	/**
	 * 检索地址
	 */
	private String retrievUrl;

	/**
	 * 检索地址
	 * @return
	 */
	public String getRetrievUrl() {
		return retrievUrl;
	}

	/**
	 * 检索地址
	 * @param retrievUrl
	 */
	public void setRetrievUrl(String retrievUrl) {
		this.retrievUrl = retrievUrl;
	}

	/**
	 * jap数据表格操作对象
	 * 
	 * @param cls 实体类型
	 * @param url 更新地址
	 * @param cols
	 */
	public JSTableHttpClientBuilderImpl(Class<E> cls, String url, JSTableColumn... cols) {
		super(cls, cols);
		this.setRetrievUrl(url);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public JSTableModelLinster<Collection<E>> buildModelLinster(JSTableModel<Collection<E>> tableModel)
			throws Exception {
		JSTableModelHttpClientAdapter<E> adapter = new JSTableModelHttpClientAdapter<E>(this.cls,this.retrievUrl);
		tableModel.setTableModelLinster(adapter);
		return adapter;
	}

}
